package waggle.client;

import com.google.gwt.user.client.Event;
import com.google.gwt.user.client.ui.Image;

/**
 * The image class to generate a event when the image is fully loaded.
 *
 */

public class ImagePopUp extends Image{
    PopUpImgShow pi;
    private boolean loaded;
    public ImagePopUp(String link, PopUpImgShow pi){
            super(link);
            this.pi = pi;
    }
    /**
     * When the image is fully loaded a event is fired.
     */
    /*
     * The ONLOAD event is fired few times per second, so a flag is required.
     */
    public void onBrowserEvent(Event event) {
            if (event.getTypeInt() == Event.ONLOAD && !loaded) {
                    loaded = true;
                    pi.scaleImg(this);
            }
    }
}
